from src.repo.model.enums import *


class Deployment:

    def __init__(self, project_id, environment_id, id_=None, **kwargs):
        self.id_ = id_
        self.project_id = project_id
        self.environment_id = environment_id

    def __repr__(self):
        return str(self.__dict__)


class Project:

    def __init__(self, name, description, git_address, local_folder, id_=None, **kwargs):
        self.id_ = id_
        self.name = name
        self.description = description
        self.git_address = git_address
        self.local_folder = local_folder

    def __repr__(self):
        return str(self.__dict__)


class Environment:
    def __init__(self, project_id, name, id_=None, **kwargs):
        self.id_ = id_
        self.project_id = project_id
        self.name = name

    def __repr__(self):
        return str(self.__dict__)


class DeploymentMergeBranch:
    def __init__(self, deployment_id, branch_name, status: DeleteStatus, id_=None, **kwargs):
        self.id_ = id_
        self.deployment_id = deployment_id
        self.branch_name = branch_name
        self.status = status

    def __repr__(self):
        return str(self.__dict__)


class Branch:
    def __init__(self, project_id, feature_id, branch_name, status: BranchStatus, id_=None, feature_name=None,
                 **kwargs):
        self.id_ = id_
        self.project_id = project_id
        self.feature_id = feature_id
        self.feature_name = feature_name
        self.branch_name = branch_name
        self.status = status

    def __repr__(self):
        return str(self.__dict__)


class Feature:
    def __init__(self, name, description, url, status: FeatureStatus, id_=None, **kwargs):
        self.id_ = id_
        self.name = name
        self.description = description
        self.url = url
        self.status = status

    def __repr__(self):
        return str(self.__dict__)


class DeploymentBranch:
    def __init__(self, branch_id, deployment_id, latest_commit, id_=None, branch_name=None,
                 feature_id=None, feature_name=None, branch_latest_commit=None, local_folder=None, **kwargs):
        """
        latest_commit: 部署中的分支最新提交
        ranch_latest_commit: 分支实际最新提交
        """
        self.id_ = id_
        self.branch_id = branch_id
        self.branch_name = branch_name
        self.deployment_id = deployment_id
        self.latest_commit = latest_commit
        self.feature_id = feature_id
        self.feature_name = feature_name
        self.local_folder = local_folder
        self.branch_latest_commit = branch_latest_commit

    def __repr__(self):
        return str(self.__dict__)


class DeploymentProcess:
    def __init__(self, environment_id, deployment_id, status, process_log, finished_time=None, id_=None, **kwargs):
        self.id_ = id_
        self.environment_id = environment_id
        self.deployment_id = deployment_id
        self.status = status
        self.process_log = process_log
        self.finished_time = finished_time

    def __repr__(self):
        return str(self.__dict__)
